let path = require("path");
// const webpack = require("webpack");
function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: "./",
  assetsDir: "static",

  // 是否在构建生产包时生成sourcdeMap
  productionSourceMap: false,

  chainWebpack: (config) => {
    config.resolve.alias
      .set("@", resolve("src"))
      .set("@v", resolve("src/views"))
      .set("@c", resolve("src/components"));
    config.optimization.runtimeChunk("single");
  },

  devServer: {
    /* 自动打开浏览器 */
    open: true,
    port: 8080,
    https: false,
    hotOnly: false,
    /* 使用代理 */
    proxy: {
      "/api": {
        target: "http://10.10.1.45:3000/api",
        /* 允许跨域 */
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          "^/api": "",
        },
      },
    },
  },

  configureWebpack: {
    //支持jquery
    plugins: [],
  },

  css: {
    sourceMap: true, // 是否为 CSS 开启 source map
    loaderOptions: {
      less: {},
    },
  },

  pluginOptions: {
    "style-resources-loader": {
      preProcessor: "scss",
      patterns: [path.resolve(__dirname, "./public/styles/common.scss")],
    },
  },
};
